package com.isdepci.project.eleLoad.controller;

import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.framework.web.page.TableDataInfo;
import com.isdepci.project.eleLoad.domain.AMachineryQuota;
import com.isdepci.project.eleLoad.service.IAMachineryQuotaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 机械台班定额Controller
 *
 * @author isdepci
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/eleLoad/machineryQuota")
public class AMachineryQuotaController extends BaseController
{
    @Autowired
    private IAMachineryQuotaService aMachineryQuotaService;

    /**
     * 查询机械台班定额列表
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:machineryQuota:list')")
    @GetMapping("/list")
    public TableDataInfo list(AMachineryQuota aMachineryQuota)
    {
        startPage();
        List<AMachineryQuota> list = aMachineryQuotaService.selectAMachineryQuotaList(aMachineryQuota);
        return getDataTable(list);
    }

    /**
     * 导出机械台班定额列表
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:machineryQuota:export')")
    @Log(title = "机械台班定额", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AMachineryQuota aMachineryQuota)
    {
        List<AMachineryQuota> list = aMachineryQuotaService.selectAMachineryQuotaList(aMachineryQuota);
        ExcelUtil<AMachineryQuota> util = new ExcelUtil<AMachineryQuota>(AMachineryQuota.class);
        return util.exportExcel(list, "machineryQuota");
    }

    /**
     * 获取机械台班定额详细信息
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:machineryQuota:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aMachineryQuotaService.selectAMachineryQuotaById(id));
    }

    /**
     * 新增机械台班定额
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:machineryQuota:add')")
    @Log(title = "机械台班定额", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AMachineryQuota aMachineryQuota)
    {
        return toAjax(aMachineryQuotaService.insertAMachineryQuota(aMachineryQuota));
    }

    /**
     * 修改机械台班定额
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:machineryQuota:edit')")
    @Log(title = "机械台班定额", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AMachineryQuota aMachineryQuota)
    {
        return toAjax(aMachineryQuotaService.updateAMachineryQuota(aMachineryQuota));
    }

    /**
     * 删除机械台班定额
     */
    @PreAuthorize("@ss.hasPermi('eleLoad:machineryQuota:remove')")
    @Log(title = "机械台班定额", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aMachineryQuotaService.deleteAMachineryQuotaByIds(ids));
    }
}
